package com.iplay.service.totp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iplay.component.totp.TOTPAuthenticator;

@Service
public class TOTPServiceImpl implements TOTPService{
	
	private static final String DEFAULT_TOTP_SECRET_KEY = "KWNDSEYBDCXINSN_=UIWOSMHFJLALJSWEKKXNSK";

	@Autowired
	private TOTPAuthenticator authenticator;
	
	@Override
	public String generateTOTPUsingDefaultSecretKey() {
		return authenticator.generateTotpUsingBase64Decoder(DEFAULT_TOTP_SECRET_KEY);
	}
	

	@Override
	public boolean validateTOTPUsingDefaultSecretKey(String totp) {
		return authenticator.validateTotpUsingBase64Decoder(DEFAULT_TOTP_SECRET_KEY, totp);
	}

}
